<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<ui:composition 
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    template="/template.xhtml"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:f="http://java.sun.com/jsf/core">
    
    <ui:define name="title"></ui:define>
    <ui:define name="content">
     <!--   <c:if test="#{userBean.currentUser.role == 'ADMIN'}"> -->
        
        <div id="adminmenu">
              <ui:include src="./menu.xhtml"></ui:include> 
        </div>
        <h3>Номерной фонд отеля</h3>
         <div id="dataM">
        <div class="dataExport">
            <h:form>  
            <h:panelGrid columns="2">  
                <p:panel header="Експортировать все данные">  
                    <h:commandLink>  
                        <p:graphicImage value="/img/xls.png" />  
                        <p:dataExporter type="xls" target=":roomList:allRooms" fileName="rooms" />  
                    </h:commandLink>  

                    <h:commandLink>  
                        <p:graphicImage value="/img/file_pdf.png" />  
                        <p:dataExporter type="pdf" target=":roomList:allRooms" fileName="rooms"/>  
                    </h:commandLink>  

                    <h:commandLink>  
                        <p:graphicImage value="/img/csv_text.png" />  
                        <p:dataExporter type="csv" target=":roomList:allRooms" fileName="rooms" />  
                    </h:commandLink>  

                    <h:commandLink>  
                        <p:graphicImage value="/img/file_xml.png" />  
                        <p:dataExporter type="xml" target=":roomList:allRooms" fileName="rooms" />  
                    </h:commandLink>  
                </p:panel>  
                
                
            </h:panelGrid>    
           </h:form>
         </div>
            
        
        <div class="btnRight">
            <p:commandButton id="basic" value="Добавить новый номер" onclick="dlg.show();" type="button" />
            <p:dialog width="800" header="Создание нового пользователя" widgetVar="dlg" maximizable="true" minimizable="true">  
            <h:form prependId="false">
                <h:panelGrid columns="2" columnClasses="column" cellpadding="5"> 
                    <h:outputText value="Номер комнаты"/> 
                    <p:inputText value="#{hotelRoomBean.newHotelRoom.numberRoom}"/>
                    <h:outputText value="Количество мест"/> 
                    <p:inputText value="#{hotelRoomBean.newHotelRoom.countSeats}"/>
                    <h:outputText value="Категория номера"/>
                    <p:inputText value="#{hotelRoomBean.newHotelRoom.category}"/>
                    <h:outputText value="Цена за сутки"/> 
                    <p:inputText value="#{hotelRoomBean.newHotelRoom.price}"/>
                    <h:outputText value="Информаци о номере"/> 
                    <p:inputTextarea  cols="70" value="#{hotelRoomBean.newHotelRoom.info}"/>
                    <h:outputText value="Тип питания"/> 
                        <h:selectOneMenu value="#{hotelRoomBean.newHotelRoom.typeOfFood}">
                            <f:selectItems value="#{hotelRoomBean.typeOfFood}"
                                                   var="type"
                                                   itemLabel="#{type}"
                                                   itemValue="#{type}"
                                                   >
                                    </f:selectItems>
                                </h:selectOneMenu>
                    <h:outputText value="класификация номера"/> 
                        <h:selectOneMenu value="#{hotelRoomBean.newHotelRoom.classification}">
                            <f:selectItems value="#{hotelRoomBean.classification}"
                                                   var="type1"
                                                   itemLabel="#{type1}"
                                                   itemValue="#{type1}"
                                                   >
                                    </f:selectItems>
                                </h:selectOneMenu>
  
                    
                </h:panelGrid>
                
                
               
                
                <h:commandButton class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" value="Создать"   actionListener="#{hotelRoomBean.saveHotelRoom}"/>
            </h:form>
        </p:dialog>  
        </div>
         </div>
         <h:form id="roomList" >
            
            <p:contextMenu for="allRooms">
                <p:menuitem value="Просмотреть" update="d" icon="ui-icon-search" oncomplete="roomDislay.show()"/>
                <p:menuitem value="Удалить" update="allRooms" icon="ui-icon-close" actionListener="#{hotelRoomBean.deleteCurentHotelRoom}"/>
            </p:contextMenu>
            
            <p:growl id="messages" showDetail="true"/>
            <p:dataTable paginator="true" rows="15" var="room" value="#{hotelRoomBean.allHotelRooms}"  id="allRooms" rowKey="#{room.numberRoom}" 
                         selection="#{hotelRoomBean.selectedRoom}" selectionMode="single"
                         >
                  
                   
                <p:column headerText="Номер комнаты" sortBy="#{room.numberRoom}" filterBy="#{room.numberRoom}" style="width: 5%">
                    <h:outputText value="#{room.numberRoom}"/>
                </p:column>
                    
                <p:column headerText="Количесво мест" sortBy="#{room.countSeats}" filterBy="#{room.countSeats}" style="width: 5%">
                    <h:outputText value="#{room.countSeats}"/>
                </p:column>
                <p:column headerText="Категория" sortBy="#{room.category}" filterBy="#{room.category}" style="width: 5%">
                    <h:outputText value="#{room.category}"/>
                </p:column>    
                <p:column headerText="Цена за одну ночь" sortBy="#{room.price}" filterBy="#{room.price}" style="width: 5%">
                    <h:outputText value="#{room.price}"/>
                </p:column>
               
                   
                   
                   
             </p:dataTable>  
               
                   <p:dialog header="Подробная информация о номере" widgetVar="roomDislay" resizable="false"
                             width="800" showEffect="clips" hideEffect="fold" id="d1">
                       <h:panelGrid id="d" columns="2">
                           
                           <h:outputText value="Номер комнаты"/>
                           <h:outputText value="#{hotelRoomBean.selectedRoom.numberRoom}"/>
                           <h:outputText value="Категория"/>
                           <h:outputText value="#{hotelRoomBean.selectedRoom.category}"/>
                           <h:outputText value="Количество мест"/>
                           <h:outputText value="#{hotelRoomBean.selectedRoom.countSeats}"/>
                           <h:outputText value="Цена"/>
                           <h:outputText value="#{hotelRoomBean.selectedRoom.price} грн."/>
                           <h:outputText value="Класификация номера"/>
                           <h:outputText value="#{hotelRoomBean.selectedRoom.classification}"/>
                           <h:outputText value="Тип питания"/>
                           <h:outputText value="#{hotelRoomBean.selectedRoom.typeOfFood}"/>
                           <h:outputText value="Информация"/>
                           <h:outputText value="#{hotelRoomBean.selectedRoom.info}"/>
                       </h:panelGrid>
                        <p:commandButton value="Print" type="button" icon="ui-icon-print">  
                             <p:printer target="d" />  
                        </p:commandButton>  
                   </p:dialog>
        </h:form>
       
        
      
       <!-- </c:if> -->
    </ui:define>
</ui:composition>
